package diwuzhang;
import java.util.Scanner;
public class SimpleCalculator {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double num1, num2, result;
        char operator;
        System.out.print("请输入第一个数字：");
        num1 = scanner.nextDouble();
        System.out.print("请输入第二个数字：");
        num2 = scanner.nextDouble();
        System.out.print("请输入运算符（+、-、*、/）：");
        operator = scanner.next().charAt(0);
        switch (operator) {
            case '+':
                result = num1 + num2;
                break;
            case '-':
                result = num1 - num2;
                break;
            case '*':
                result = num1 * num2;
                break;
            case '/':
                if (num2 == 0) {
                    System.out.println("除数不能为0，请重新输入。");
                    return;
                }
                result = num1 / num2;
                break;
            default:
                System.out.println("无效的运算符，请重新输入。");
                return;
        }
        System.out.println("结果为：" + result);
    }
}
